#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <gmp.h>
#include "borwein.h"

#define MAX_IT 15
#define IT_FILENAME "resultados/seq"
#define F_PREC 33219613

int main (int argc, char** argv){
	unsigned int it = 0, t;

	t = time(NULL);	

	mpf_set_default_prec(F_PREC);

	init_vars();
	set_init_vals();
	
	do{
		calc_yk();
		update_yk();
		ak_pre_calc();
		ak_end_calc();
		update_ak();
		calc_pi();
		save_it(IT_FILENAME);
	} while ( check_erro() && MAX_IT > ++it);

	printf("Tempo total %d segundos.\n", (int) time(NULL)-t);

	clear_vars();

	return EXIT_SUCCESS;
}
